<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('订单管理列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>商户：</label>
                            <div class="col-sm-8">
                                <select id="merchantId" name="merchantId" class="form-control">
                                    <option value="">---选择---</option>
                                    <option th:each="merchant : ${merchantList}" th:value="${merchant.merchantId}"
                                            th:text="${merchant.merchantName}"></option>
                                </select>
                            </div>
                        </li>
                        <li>
                            <label class="col-sm-3 control-label">业务：</label>
                            <div class="col-sm-8">
                                <select id="tranType" name="tranType" class="form-control">
                                    <option value="">---选择---</option>
                                    <option th:each="busi : ${busiList}" th:value="${busi.id}"
                                            th:text="${busi.name}"></option>
                                </select>
                            </div>
                        </li>
                        <li>
                            <label>渠道：</label>
                            <div class="col-sm-8">
                                <select id="channelId" name="channelId" class="form-control">
                                    <option value="">---选择---</option>
                                    <option th:each="channel : ${channelList}" th:value="${channel.channelId}"
                                            th:text="${channel.channelName}"></option>
                                </select>
                            </div>
                        </li>
                        <li>
                            <label>商户订单号：</label>
                            <div class="col-sm-8">
                                <input type="text" name="merTradeNo"/>
                            </div>
                        </li>
                        <li>
                            <label>渠道订单号：</label>
                            <div class="col-sm-8">
                                <input type="text" name="chaTradeNo"/>
                            </div>
                        </li>
                        <li>
                            <label>交易状态：</label>
                            <div class="col-sm-8">
                                <select id="respCode" name="respCode" class="form-control">
                                    <option value="">---选择---</option>
                                    <option value="0000">成功</option>
                                    <option value="0001">处理中</option>
                                    <option value="fail">失败</option>
                                </select>
                            </div>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <!--            <div class="btn-group-sm" id="toolbar" role="group">-->
        <!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="mng:order:add">-->
        <!--                    <i class="fa fa-plus"></i> 添加-->
        <!--                </a>-->
        <!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="mng:order:edit">-->
        <!--                    <i class="fa fa-edit"></i> 修改-->
        <!--                </a>-->
        <!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="mng:order:remove">-->
        <!--                    <i class="fa fa-remove"></i> 删除-->
        <!--                </a>-->
        <!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="mng:order:export">-->
        <!--                    <i class="fa fa-download"></i> 导出-->
        <!--                </a>-->
        <!--            </div>-->
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('mng:order:edit')}]];
        var removeFlag = [[${@permission.hasPermi('mng:order:remove')}]];
        var prefix = ctx + "mng/order";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                detailUrl: prefix + "/detail/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "订单管理",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'orderId',
                    title: '订单ID',
                    visible: false
                },
                {
                    field: 'merTradeNo',
                    title: '商户订单号'
                },
                {
                    field: 'chaTradeNo',
                    title: '渠道订单号'
                },
                {
                    field: 'extend_merchantName',
                    title: '商户'
                },
                {
                    field: 'extend_channelName',
                    title: '渠道'
                },
                {
                    field: 'extend_busiName',
                    title: '业务'
                },
                {
                    field: 'amt',
                    title: '交易金额(元)',
                    formatter: function (value, row, index) {
                        return Money(value)
                    }
                },
                {
                    field: 'respCode',
                    title: '交易状态',
                    formatter: function(value, item, index) {
                        if(value === '0000'){
                            return '<span style="color:green">成功</span>'
                        }
                        else if(value === '0001'){
                            return '<span style="color:gray">处理中</span>'
                        }else{
                            return '<span style="color:purple">失败</span>'
                        }
                    }
                },
                {
                    field: 'createTime',
                    title: '发生时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.orderId + '\')"><i class="fa fa-info"></i>详情</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function Money(num) {
            if (!num) {
                return '0.00'
            }
            num = new BigNumber(num)
            num = num.div(100).toString()
            num = num.split(".");  // 分隔小数点
            var arr = num[0].split("").reverse();  // 转换成字符数组并且倒序排列
            var res = [];
            for (var i = 0, len = arr.length; i < len; i++) {
                if (i % 3 === 0 && i !== 0) {
                    res.push(",");   // 添加分隔符
                }
                res.push(arr[i]);
            }
            res.reverse(); // 再次倒序成为正确的顺序
            if (num[1]) {  // 如果有小数的话添加小数部分
                res = res.join("").concat("." + num[1]);
            } else {
                res = res.join("").concat(".00");
            }
            return res;
        }





</script>
</body>
</html>